/*
 * @lc app=leetcode.cn id=283 lang=cpp
 *
 * [283] 移动零
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int cnt = 0;
        vector<int> ans;

        for(auto n : nums)
        {
            if(n != 0) ans.push_back(n);
            else ++cnt;
        }

        nums.swap(ans);
        while(cnt-- > 0)
        {
            nums.push_back(0);
        }
    }
};
// @lc code=end

